package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据菜品id查询对应的套餐
     * @Param dishIds
     * @return
     * */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 新增菜品
     * @param dish
     * * @return
     * */
    @Insert( "insert into setmeal_dish(setmeal_id ,dish_id,name, price,copies) values (#{setmealId},#{dishId},#{name},#{price},#{copies})")
    void insert(SetmealDish dish);

    /**
     * 修改套餐
     * @param setmealId
     * @return
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    void deleteBySetmealID(Long setmealId);

    /**
     * 根据套餐id查询关联的菜品
     * @Param Id
     * @return
     * */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
 List<SetmealDish> getSetmealId(Long id);

    /**
     * 批量删除套餐
     *  @param ids
     * @return
     * */
    void delete(List<Long> ids);
}